<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>
Bugzilla::Field::Choice</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" title="style" type="text/css" href="../.././../../../style.css" media="all" >

</head>
  <body id="pod">
<p class="backlinktop"><b><a name="___top" href="../../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
<h1>Bugzilla::Field::Choice</h1>
<div class='indexgroup'>
<ul   class='indexList indexList1'>
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
  <ul   class='indexList indexList2'>
    <li class='indexItem indexItem2'><a href='#Class_Factory'>Class Factory</a>
    <li class='indexItem indexItem2'><a href='#Accessors'>Accessors</a>
  </ul>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>Bugzilla::Field::Choice - A legal value for a &#60;select&#62;-type field.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<pre  class="code"> my $field = new Bugzilla::Field({name =&#62; &#39;bug_status&#39;});

 my $choice = new Bugzilla::Field::Choice-&#62;type($field)-&#62;new(1);

 my $choices = Bugzilla::Field::Choice-&#62;type($field)-&#62;new_from_list([1,2,3]);
 my $choices = Bugzilla::Field::Choice-&#62;type($field)-&#62;get_all();
 my $choices = Bugzilla::Field::Choice-&#62;type($field-&#62;match({ sortkey =&#62; 10 }); </pre>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>This is an implementation of <a href="../../Bugzilla/Object.html" class="podlinkpod"
>Bugzilla::Object</a>, but with a twist. You can&#39;t call any class methods (such as <code  class="code">new</code>, <code  class="code">create</code>, etc.) directly on <code  class="code">Bugzilla::Field::Choice</code> itself. Instead, you have to call <code  class="code">Bugzilla::Field::Choice-&#62;type($field)</code> to get the class you&#39;re going to instantiate, and then you call the methods on that.</p>

<p>We do that because each field has its own database table for its values, so each value type needs its own class.</p>

<p>See the <a href="#SYNOPSIS" class="podlinkpod"
>&#34;SYNOPSIS&#34;</a> for examples of how this works.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Class_Factory"
>Class Factory</a></h2>

<p>In object-oriented design, a &#34;class factory&#34; is a method that picks and returns the right class for you, based on an argument that you pass.</p>

<dl>
<dt><a name="type"
><code  class="code">type</code></a></dt>

<dd>
<p>Takes a single argument, which is either the name of a field from the <code  class="code">fielddefs</code> table, or a <a href="../../Bugzilla/Field.html" class="podlinkpod"
>Bugzilla::Field</a> object representing a field.</p>

<p>Returns an appropriate subclass of <code  class="code">Bugzilla::Field::Choice</code> that you can now call class methods on (like <code  class="code">new</code>, <code  class="code">create</code>, <code  class="code">match</code>, etc.)</p>

<p><b>NOTE</b>: YOU CANNOT CALL CLASS METHODS ON <code  class="code">Bugzilla::Field::Choice</code>. You must call <code  class="code">type</code> to get a class you can call methods on.</p>
</dd>
</dl>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Accessors"
>Accessors</a></h2>

<p>These are in addition to the standard <a href="../../Bugzilla/Object.html" class="podlinkpod"
>Bugzilla::Object</a> accessors.</p>

<dl>
<dt><a name="sortkey"
><code  class="code">sortkey</code></a></dt>

<dd>
<p>The key that determines the sort order of this item.</p>

<dt><a name="field"
><code  class="code">field</code></a></dt>

<dd>
<p>The <a href="../../Bugzilla/Field.html" class="podlinkpod"
>Bugzilla::Field</a> object that this field value belongs to.</p>

<dt><a name="controlled_values"
><code  class="code">controlled_values</code></a></dt>

<dd>
<p>Tells you which values in <b>other</b> fields appear (become visible) when this value is set in its field.</p>

<p>Returns a hashref of arrayrefs. The hash keys are the names of fields, and the values are arrays of <code  class="code">Bugzilla::Field::Choice</code> objects, representing values that this value controls the visibility of, for that field.</p>
</dd>
</dl>
<p class="backlinkbottom"><b><a name="___bottom" href="../../index.html" title="All Documents">&lt;&lt;</a></b></p>

<!-- end doc -->

</body></html>
